Skip to content

Fix ABBA deadlock between waitForTransform and testTransformableRequests (backport #982) - #988

Open
mergify[bot] wants to merge 2 commits into
kiltedfrom
mergify/bp/kilted/pr-982
Open

Fix ABBA deadlock between waitForTransform and testTransformableRequests (backport #982)#988
mergify[bot] wants to merge 2 commits into
kiltedfrom
mergify/bp/kilted/pr-982

Conversation

@mergify

@mergify mergify Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Description

As mentioned in #979, an ABBA deadlock situation was introduced in #966 where testTransformableRequests() locks transformable_requests_mutex_ and tries to run cb which requires timer_to_request_map_mutex_ while parallely waitForTransform acquires timer_to_request_map_mutex_ and tries to call addTransformableRequest which internally needs transformable_requests_mutex_ resulting in ABBA situation.

My apologies for not noticing this issue previously and a special thanks to @jplapp and @mini-1235 for bringing it to my attention.

@mini-1235 has already opened #979 to fix this issue. I agree with the approach in that PR (to unlock mutex before running callbacks and lock again) but I think restarting the i and going through the beginning of the requests for every callback would add unnecessary computation time. More precisely, the cost is that if M callbacks fire per setTransform and N requests are pending, you get O(M·N) work instead of O(N).

I tried to improve that by going through the requests first, extracting the pending callbacks and then running them. That way we keep the swap-and-pop behavior as before.

I have also copied the test @jplapp added in #980 here as well. @mini-1235 could you please also check this in your nav2 setup where this problem became highlighted?

Credits to @jplap and @mini-1235 for their idea and suggested changes.

Did you use Generative AI?

Yes, Claude Sonned 4.6


This is an automatic backport of pull request #982 done by [Mergify](https://mergify.com).

…sts (#982)

(cherry picked from commit 16cfc11)

# Conflicts:
#	tf2/src/buffer_core.cpp
@mergify

mergify Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

Cherry-pick of 16cfc11 has failed:

On branch mergify/bp/kilted/pr-982
Your branch is up to date with 'origin/kilted'.

You are currently cherry-picking commit 16cfc11.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   tf2_ros/test/test_buffer.cpp

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   tf2/src/buffer_core.cpp

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

Signed-off-by: Alejandro Hernandez Cordero <ahcorde@gmail.com>
@ahcorde

ahcorde commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Pulls: #988
Gist: https://gist.githubusercontent.com/ahcorde/6fc8519dae125c8898206f05560c4833/raw/67c3ff38365ec7493f217e00b46a2838190f0283/ros2.repos
BUILD args: --packages-above-and-dependencies tf2 tf2_ros
TEST args: --packages-above tf2 tf2_ros
ROS Distro: kilted
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/20358

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants